package com.pxst.sys.controller;

import com.pxst.annotations.LogOperate;
import com.pxst.req.*;
import com.pxst.resp.ApiResp;
import com.pxst.resp.PageResp;
import com.pxst.sys.entity.SysCurrencyConfigEntity;
import com.pxst.sys.req.CurrencyCreateRsp;
import com.pxst.sys.req.CurrencyDeleteRsp;
import com.pxst.sys.req.CurrencySelectReq;
import com.pxst.sys.req.CurrencyUpdateReq;
import com.pxst.sys.service.SysCurrencyConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sys/currency")
@Api(tags = "币种配置")
public class SysCurrencyConfigConroller {

    @Autowired
    private SysCurrencyConfigService sysCurrencyConfigService;

    @PostMapping("/create")
//    @ApiOperation(value = "新增币种")
//    @LogOperate(operate = "新增币种")
//    @PreAuthorize("@ss.hasAnyPermissions('system:curr:create')")
    public ApiResp<String> currencyCreate(@RequestBody @Valid CurrencyCreateRsp currencyCreateRsp){
        return sysCurrencyConfigService.currencyCreate(currencyCreateRsp);
    }

    @PutMapping ("/update")
//    @ApiOperation(value = "修改币种")
//    @LogOperate(operate = "修改币种")
//    @PreAuthorize("@ss.hasAnyPermissions('system:curr:update')")
    public ApiResp<String> currencyUpdate(@RequestBody @Valid CurrencyUpdateReq sysCurrencyConfigReq){
        return sysCurrencyConfigService.currencyUpdate(sysCurrencyConfigReq);
    }

    @DeleteMapping("/delete")
//    @ApiOperation(value = "删除币种")
//    @LogOperate(operate = "删除币种")
//    @PreAuthorize("@ss.hasAnyPermissions('system:curr:delete')")
    public ApiResp<String> currencyDelete(@RequestBody @Valid CurrencyDeleteRsp deleteReq){
        return sysCurrencyConfigService.currencyDelete(deleteReq);
    }

//    @GetMapping("/select")
//    @ApiOperation(value = "查询币种")
//    @LogOperate(operate = "查询币种")
//    @PreAuthorize("@ss.hasAnyPermissions('system:curr:select')")
//    public ApiResp<String> currencySelect(CurrencySelectReq currencyPageReq){
//        return sysCurrencyConfigService.currencySelect(currencyPageReq);
//    }

    @GetMapping("/selectAll")
//    @ApiOperation(value = "分页查询币种")
//    @LogOperate(operate = "分页查询币种")
//    @PreAuthorize("@ss.hasAnyPermissions('system:curr:selectAll')")
    public List<String> currencyPage(){
        return sysCurrencyConfigService.currencyList();
    }
}
